<!DOCTYPE html>
<html>
<head>
  <title>Test - StringBuilder</title>
  <link rel="stylesheet" href="../QUnit.css" type="text/css" />
  <script type="text/javascript" src="../QUnit.js"></script>
  <script type="text/javascript" src="../QUnitExt.js"></script>
</head>
<body>
  <h1 id="qunit-header">Test Results</h1>
  <h2 id="qunit-banner"></h2>
  <h2 id="qunit-userAgent"></h2>
  <ol id="qunit-tests"></ol>
  <br />
  <textarea id="qunit-log" rows="10" cols="100"></textarea>
  <script type="text/javascript" src="../Scripts/Sharpen.debug.js"></script>
  <script type="text/javascript">
  module('StringBuilder');

  test('initialization', function() {
    var sb1 = new ss.StringBuilder();
    var sb2 = new ss.StringBuilder('abc');

    QUnit.equal(sb1.toString(), '');
    QUnit.equal(sb1.isEmpty, true);
    
    QUnit.equal(sb2.toString(), 'abc');
    QUnit.equal(sb2.isEmpty, false);
  });

  test('clear', function() {
    var sb = new ss.StringBuilder();

    sb.append('abc');
    QUnit.equal(sb.toString(), 'abc');
    QUnit.equal(sb.isEmpty, false);

    sb.clear();
    QUnit.equal(sb.toString(), '');
    QUnit.equal(sb.isEmpty, true);
  });

  test('append', function() {
    var sb = new ss.StringBuilder();

    sb.append('abc');
    sb.append('abc');
    sb.append('def');
    QUnit.equal(sb.toString(), 'abcabcdef');
  });

  test('appendLine', function() {
    var sb = new ss.StringBuilder();

    sb.append('abc');
    sb.appendLine('abc');
    sb.append('def');
    QUnit.equal(sb.toString(), 'abcabc\r\ndef');
  });

  test('appendCoercion', function() {
    var sb = new ss.StringBuilder();

    sb.append('abc');
    sb.append(123);
    sb.append(true);
    sb.append(false);
    sb.append([1,2]);
    QUnit.equal(sb.toString(), 'abc123truefalse1,2');
  });

  test('toStringSeparator', function() {
    var sb = new ss.StringBuilder();

    sb.append('abc');
    sb.append(123);
    sb.append(true);
    sb.append(false);
    sb.append([1,2]);
    QUnit.equal(sb.toString(':'), 'abc:123:true:false:1,2');
  });
  </script>
</body>

</html>
